﻿@using ETD.Common.Extension;
@using ETD.WebOrganization.Libs.Helper;
@using ETD.WinClient.Config;
@using ETD.Domain.EnumModels;
@using ETD.Domain.WebModels;
@using ETD.Common;
@model ETD.WebOrganization.Areas.Web.Models.SelfInfoModel
@{
    ViewBag.Title = "个人中心";
    var userInfoItem = Model.UserInfoItem;
    var organizationItem = Model.OrganizationItem;
}

<style>
    .weui-center {
        text-align: center;
    }

    .menu_item_left_icon {
        width: 22px !important;
        margin-right: 8px !important;
        display: block;
    }

    .WpSecurityTableLink {
    }

    .weui-form-preview__ft {
        margin-top: 45px;
    }
</style>
<div class="weui-panel">

    <div class="weui-panel__bd">
        <a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
            <div class="weui-media-box__hd">
                <img class="weui-media-box__thumb" src="@Url.MapMvcAssets("Images/icon_head_gray.png")">
            </div>
            <div class="weui-media-box__bd">
                <h4 class="weui-media-box__title">@userInfoItem.RealName</h4>
                <p class="weui-media-box__desc">@organizationItem.Name</p>
            </div>
        </a>

    </div>


    <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__hd"><img class="menu_item_left_icon" src="@Url.MapMvcAssets("Images/icon_info_gray.png")"></div>
            <div class="weui-cell__bd">
                <p>账号</p>
            </div>
            <div class="weui-cell__ft">@userInfoItem.UserName</div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><img class="menu_item_left_icon" src="@Url.MapMvcAssets("Images/icon_info_gray.png")"></div>
            <div class="weui-cell__bd">
                <p>姓名</p>
            </div>
            <div class="weui-cell__ft">@userInfoItem.RealName</div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><img class="menu_item_left_icon" src="@Url.MapMvcAssets("Images/icon_info_gray.png")"></div>
            <div class="weui-cell__bd">
                <p>手机</p>
            </div>
            <div class="weui-cell__ft">@userInfoItem.Mobile</div>
        </div>
    </div>
    <div class="weui-form-preview__ft">
        <a class="weui-form-preview__btn weui-form-preview__btn_default" href="javascript:">辅助操作</a>
        <button type="submit" class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:">操作</button>
    </div>
</div>

@section ScriptSection{
    <script>
        $(function () { CurrentSecurityTableObject.Init(); });
        var CurrentSecurityTableObject = {
            Init: function () {
                $(".WpSecurityTableLink").click(CurrentSecurityTableObject.OnWpSecurityTableLinkClick);
            },
            OnWpSecurityTableLinkClick: function () {
                $this = $(this);
                console.log($this.data("name"));
                console.log($this.data("wpsecuritytableid"));
                CurrentSecurityTableObject.SelectedWpSecurityTableLink = {
                    "Name": $this.data("name"),
                    "WpSecurityTableID": $this.data("wpsecuritytableid")
                };
                CurrentSecurityTableObject.OpenActionMenu();
            },
            SelectedWpSecurityTableLink: null,
            OpenActionMenu: function () {
                $.actions({
                    title: "选择操作",
                    onClose: function () {
                        console.log("close");
                    },
                    actions: [
                      {
                          text: "切换到>>" + CurrentSecurityTableObject.SelectedWpSecurityTableLink.Name,
                          className: "color-primary",
                          onClick: function () {
                              CurrentSecurityTableObject.OnActionMenuSwitchClick();
                          }
                      },
                      //{
                      //    text: "删除",
                      //    className: 'color-danger',
                      //    onClick: function() {
                      //        $.alert("你选择了“删除”");
                      //    }
                      //}
                    ]
                });
            },
            OnActionMenuSwitchClick: function () {
                var paras = {};
                paras.WpSecurityTableID = CurrentSecurityTableObject.SelectedWpSecurityTableLink.WpSecurityTableID;
                ajaxPost("@Url.Action("SwitchToWpSecurityTable", "SecurityTable")", paras, function (data) {
                    console.log(data);
                    if (data.Status) {
                        $.toast("操作完成!");
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                    } else {
                        $.toast(data.Info, "forbidden");
                    }
                });

            }

        };

    </script>
}